module PutJSONTest(tests) where

import Test.HUnit
import PutJSON
import SimpleJSON

renderJValueTest =
    TestList["string" ~: "\"foo\"" @=? renderJValue (JString "foo"),
             "number" ~: "3.5" @=? renderJValue (JNumber 3.5),
             "empty array" ~: "[]" @=? renderJValue (JArray []),
             "one element array" ~: "[1.0]" @=?
                                 renderJValue (JArray [JNumber 1]),
             "multiple element array" ~: "[1.0, 2.0, 3.0]" @=?
                                      renderJValue (JArray [JNumber 1,
                                                            JNumber 2,
                                                            JNumber 3]),
             "special types" ~: "[true, false, null]" @=?
                             renderJValue (JArray [JBool True, JBool False,
                                                   JNull]),
             "empty object" ~: "{}" @=?
                            renderJValue (JObject []),
             "one element object" ~: "{\"foo\": 1.0}" @=?
                                  renderJValue (JObject [("foo", JNumber 1)]),
             "multiple element object" ~:
               "{\"foo\": 1.0, \"bar\": 2.0, \"baz\": 3.0}" @=?
               renderJValue (JObject [("foo", JNumber 1),
                                      ("bar", JNumber 2),
                                      ("baz", JNumber 3)])
            ]

tests = renderJValueTest
